package org.xq.shop.maxaishop.service.impl;

import org.springframework.stereotype.Service;
import org.xq.shop.maxaishop.dao.XqAddressDao;
import org.xq.shop.maxaishop.entity.XqAddress;
import org.xq.shop.maxaishop.service.XqAddressService;

import javax.annotation.Resource;
import java.util.List;

/**
 * (XqAddress)表服务实现类
 *
 * @author makejava
 * @since 2021-06-17 19:55:10
 */

@Service("xqAddressService")
public class XqAddressServiceImpl implements XqAddressService {
    @Resource
    private XqAddressDao xqAddressDao;

    /**
     * 通过ID查询单条数据
     *
     * @param aid 主键
     * @return 实例对象
     */

    @Override
    public XqAddress queryById(Integer aid) {
        return this.xqAddressDao.queryById(aid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<XqAddress> queryAllByLimit(int offset, int limit) {
        return this.xqAddressDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<XqAddress> queryByUId(Integer uid) {
        return this.xqAddressDao.queryByUId(uid);
    }

    /**
     * 新增数据
     *
     * @param xqAddress 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(XqAddress xqAddress) {
        return this.xqAddressDao.insert(xqAddress);
    }

    @Override
    public int selectCount(Integer uid) {
        return this.xqAddressDao.selectCount(uid);
    }

    /**
     * 修改数据
     *
     * @param xqAddress 实例对象
     * @return 实例对象
     */
    @Override
    public XqAddress update(XqAddress xqAddress) {
        this.xqAddressDao.update(xqAddress);
        return this.queryById(xqAddress.getAid());
    }

    /**
     * 通过主键删除数据
     *
     * @param aid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer aid) {
        return this.xqAddressDao.deleteById(aid) > 0;
    }
}
